package org.company.ci.services;

import javax.servlet.ServletContext;

import org.apache.struts2.ServletActionContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

/**
 * 
 *  
 * @author Hudy 01/12/2010
 * @version 1.0
 */
public class ServiceFinder {
	
	
	public static Object getBean(String serviceName) {
		WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(
                ServletActionContext.getServletContext());

		return context.getBean(serviceName);
	}
	
	public static Object getBean(ServletContext context, String serviceName) {
		WebApplicationContext webAppContext = WebApplicationContextUtils
			.getRequiredWebApplicationContext(context);

		return webAppContext.getBean(serviceName);
	}

}
